package Test;

import java.util.Scanner;

/**
 * 计蒜客矩阵翻转题目答案
 */
public class Main12 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int M = input.nextInt();
        int N = input.nextInt();
        int T = input.nextInt();
        int[][] arrOld = new int[M][N];
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                arrOld[i][j] = input.nextInt();
            }
        }
        function(arrOld, T);
    }

    public static void function(int[][] arrOld, int T) {
        //表示行
        int M = arrOld.length;
        //表示列
        int N = arrOld[0].length;

        int temp;

        if (T == 0) {//表示要左右翻转
            for (int i = 0; i < M; i++) {
                for (int j = 0; j <= N / 2 - 1; j++) {
                    temp = arrOld[i][j];
                    arrOld[i][j] = arrOld[i][N - j - 1];
                    arrOld[i][N - j - 1] = temp;
                }
            }
            for (int i = 0; i < M; i++) {
                for (int j = 0; j < N; j++) {
                    System.out.print(arrOld[i][j] + " ");
                }
                System.out.println(" ");

            }
        } else if (T == 1) {//表示要上下翻转
            for (int i = 0; i <= M / 2 - 1; i++) {
                for (int j = 0; j < N; j++) {
                    temp = arrOld[i][j];
                    arrOld[i][j] = arrOld[M - i - 1][j];
                    arrOld[M - i - 1][j] = temp;
                }
            }
            for (int i = 0; i < M; i++) {
                for (int j = 0; j < N; j++) {
                    System.out.print(arrOld[i][j] + " ");
                }
                System.out.println(" ");

            }

        } else {
            System.out.println("输入的T只能为0或者1，参数错误，请重新输入");
        }
    }

}
